﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BTv2.UserControls
{
    /// <summary>
    /// Interaction logic for NotificationSettings.xaml
    /// </summary>
    public partial class NotificationSettings : UserControl
    {
        public NotificationSettings()
        {
            InitializeComponent();
        }

        private Settings _settingsWindow;

        public NotificationSettings(Settings s)
        {
            InitializeComponent();
            _settingsWindow = s;
        }

        private void NotificationSettingsLoaded(object sender, RoutedEventArgs e)
        {

            RuleNotifCheck.IsChecked = Properties.Settings.Default.RuleNotifications;
            SensorNotifCheck.IsChecked = Properties.Settings.Default.SensorNotifications;
            SensorGroupNotifCheck.IsChecked = Properties.Settings.Default.SensorGroupNotifications;
            UseNotifCheck.IsChecked = Properties.Settings.Default.UserNotifications;


        }

        private void NotificationSettingsRightClick(object sender, MouseButtonEventArgs e)
        {
            NotifSettingsMenu.IsOpen = !NotifSettingsMenu.IsOpen;
        }


        private void NSettingsBackButton(object sender, RoutedEventArgs e)
        {
            _settingsWindow.OpenMainSettings();
        }

        private void UseNotifCheck_IsCheckedChanged_1(object sender, EventArgs e)
        {
            Properties.Settings.Default.UserNotifications = (bool)UseNotifCheck.IsChecked;
            Properties.Settings.Default.Save();
        }

        private void SensorGroupNotifCheck_IsCheckedChanged_1(object sender, EventArgs e)
        {
            Properties.Settings.Default.SensorGroupNotifications = (bool)SensorGroupNotifCheck.IsChecked;
            Properties.Settings.Default.Save();
        }

        private void SensorNotifCheck_IsCheckedChanged_1(object sender, EventArgs e)
        {
            Properties.Settings.Default.SensorNotifications = (bool)SensorNotifCheck.IsChecked;
            Properties.Settings.Default.Save();
        }

        private void RuleNotifCheck_IsCheckedChanged_1(object sender, EventArgs e)
        {
            Properties.Settings.Default.RuleNotifications = (bool)RuleNotifCheck.IsChecked;
            Properties.Settings.Default.Save();
        }
    }
}
